package com.microservice.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.microservice.product.entity.ProductEntity;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * write something please~
 *
 * @author huangrz
 * @since 2021/9/14
 **/
@Repository
public interface ProductMapper extends BaseMapper<ProductEntity> {

    @Update("update tb_product set count = count - #{count}, version = version + 1 where id = #{productId} and version = #{version}")
    Integer reduce(Long productId, Integer count, Long version);
}
